import BulletAttrItem from "./bullet_attr_item";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BulletAttrItemVec2 extends BulletAttrItem {
    @property(cc.EditBox)
    ebX: cc.EditBox = null;
    @property(cc.EditBox)
    ebY: cc.EditBox = null;


    setVal(key: string, val: cc.Vec2) {
        this.lbKey.string = key;
        this.ebX.string = `${val.x}`;
        this.ebY.string = `${val.y}`;
    }
    setValAdditive(key: string, val: any): void {
        if (this.ebX.string == `${val.x}` && this.ebY.string == `${val.y}`) {
            this.diffNode.active = false;
        }
        else {
            this.diffNode.active = true;
        }
    }

    onEdit() {
        this.emit("edit", cc.v2(Number(this.ebX.string), Number(this.ebY.string)));
    }
};